<?php

namespace JsonLowCode\UI;

use JsonLowCode\Schema;
use JsonLowCode\Traits\Props\HasDisabled;
use JsonLowCode\Traits\Props\HasDisplayDirective;
use JsonLowCode\Traits\Props\HasName;
use JsonLowCode\Traits\Props\HasTitle;
use JsonLowCode\Traits\Slots\HasSlotHeader;
use JsonLowCode\Traits\Slots\HasSlotHeaderExtra;

/**
 * Collapse 组件
 * @method static CollapseItem make(string $title = null,  mixed $children = null) CollapseItem组件
 */
class CollapseItem extends Schema
{
    use HasName, HasTitle, HasDisabled, HasDisplayDirective;

    use HasSlotHeader, HasSlotHeaderExtra;

    protected string $componentName = "NCollapseItem";

    /**
     * @param string|null $title
     * @param mixed|null $children
     */
    public function __construct(string $title = null,  mixed $children = null)
    {
        parent::__construct();
        if ($title){
            $this->title($title);
        }
        $this->children($children);
    }

    /**
     * 折叠面板的自定义图标 设置 slot arrow 内容
     * (props: { collapsed: boolean })
     * @param string|array|Schema $arrow 是否是js表达式
     * @return $this
     */
    public function slotArrow(string|array|Schema $arrow): static
    {
        return $this->slot('arrow', $arrow);
    }


}
